/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.address;

import junit.framework.TestCase;

import javax.sip.address.Address;
import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class AddressImplTest extends TestCase {
    public AddressImplTest(String name) {
        super(name);
    }

    public void testCreation() {
        Address address = new AddressImpl();
        address.setURI(new SipURIImpl("deps", "deps.jnetx.ru"));
        assertEquals("The address is wrong!", "<sip:deps@deps.jnetx.ru>", address.toString());
    }

    public void testDisplayNameLazily() {
        Address address = null;
        byte[] bytes = "sip:deps@jnetx.ru".getBytes();
        try {
            address = AddressFactoryImpl.createAddressLazily(bytes, 0, bytes.length);
        } catch (ParseException e) {
            fail("cannot create an address! " + e.getMessage());
        }
        try {
            address.setDisplayName("Deps");
        } catch (ParseException e) {
            fail("Cannot set a display name! " + e.getMessage());
        }
        assertEquals("String representation is wrong!", "\"Deps\" <sip:deps@jnetx.ru>", address.toString());
    }
}
/*
 * $Log$
 */